﻿@model MVC.ViewModels.EmentaViewModel
            

@{
    ViewBag.Title = "Ementa";
    DateTime dia = Model.DiasEscolares.First().Dia;
    DateTime primeiroDia=dia;
}
<center>

<h2>Ementa da Semana : @((Model.DiasEscolares.First().Dia.DayOfYear)/7 +1)<br />Ano : @Model.DiasEscolares.First().Dia.Year <br /></h2>
   
<table>
    <tr>
    <td>Segunda</td><td>Terça</td><td>Quarta</td><td>Quinta</td><td>Sexta</td>
    </tr>

     @{
          var lista1 = new List<int>();              
       }

@for (int i = 1; i < 6; i++)
{
    <tr>
    <td>Menu @i</td><td>Menu @i</td><td>Menu @i</td><td>Menu @i</td><td>Menu @i</td> 
    </tr>
      <tr>
     

      @foreach (var item in Model.DiasEscolares)
      {
          foreach (var item2 in Model.ListaPratos)
          {
              if (item.Ementa.EmentaId == item2.Ementa.EmentaId && !lista1.Contains(item2.ListaPratosId))
              {
                 lista1.Add(item2.ListaPratosId);

                  <td>@item2.Prato.NomePrato</td>
                  break;
              }
          }

      }   
          
      
    </tr> 
}

 <tr>  
    @while (dia.DayOfWeek != DayOfWeek.Saturday)
    {

        foreach (var item in Model.DiasEscolares)
        {
            if (item.Dia.DayOfWeek == dia.DayOfWeek)
            {
         <td> Sobremesa: @item.Ementa.Sobremesa</td> 
            }
        }
        dia = dia.AddDays(1);
    }
 </tr>  

  <tr>  
   @{dia=primeiroDia;}
    @while (dia.DayOfWeek != DayOfWeek.Saturday)
    {

        foreach (var item in Model.DiasEscolares)
        {
            if (item.Dia.DayOfWeek == dia.DayOfWeek)
            {
         <td> Sopa: @item.Ementa.Sopa</td> 
            }
        }
        dia = dia.AddDays(1);

    }
  </tr>
  
  <tr>
  @{dia=primeiroDia;}  
   @while (dia.DayOfWeek != DayOfWeek.Saturday)
    {

        foreach (var item in Model.DiasEscolares)
        {
            if (item.Dia.DayOfWeek == dia.DayOfWeek)
            {
         <td>@Html.ActionLink("Escolher", "EscolherPratos", new { diaEscolar=item.DiaEscolarId, ementa = item.Ementa.EmentaId, criancaId = ViewBag.Crianca})  </td> 
            }
        }
        dia = dia.AddDays(1);
    }
  </tr>    

</table>
<br />
<br />
@Html.ActionLink("Back", "Index", new { diaActual = primeiroDia, criancaId = ViewBag.Crianca }) 
</center>